import getpass
import pexpect

child = pexpect.spawn('ssh root@192.168.80.69')

prompts = [pexpect.TIMEOUT, 'password:', 'Are you sure you want to continue connecting']
prompt_index = child.expect(prompts)
fout = open('ssh.log', 'w')
child.logfile = fout


if prompt_index == 1:
    password = getpass.getpass("Enter password: ")
    child.sendline(password)
elif prompt_index == 0:
    child.sendline('yes')

child.expect('#')

child.sendline('ls /home')
child.expect('#')

